home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / gdb / gdb_18s.zoo / atarist.c next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  18.3 KB  |  744 lines

  1.  
  2. /* glue funs and things that substitute for eunuchs funs */
  3.  
  4. #include <stdio.h>
  5. #include <osbind.h>
  6. #include <setjmp.h>
  7. #include <ctype.h>
  8. #include <signal.h>
  9. #include <regexp.h>
  10. #include "st-traps.h"
  11. #include "wait.h"
  12. #include "m-atari.h"
  13. #include "defs.h"
  14. #include "symtab.h"
  15.  
  16. struct tpa            /* what the hell does 'tpa' stand for anyway?*/
  17. {
  18.     struct tpa * self;    /* self or parent??? */
  19.     long * memtop;        /* top of mem this tpa */
  20.     long * text_base;
  21.     long text_size;
  22.     long * data_base;
  23.     long data_size;
  24.     long * bss_base;
  25.     long bss_size;
  26.     /* there's more crap here, but I think it doesn't matter */
  27. };
  28.  
  29. struct tpa * child_tpa;
  30. int atari_debug = 0;
  31.  
  32. #if 0
  33. long _stksize = 128 *1024L;    /* might as well put this here */
  34. #else
  35. long _initial_stack = 512 *1024L;
  36. #endif
  37.  
  38. #define    CHILD_PID_KLUDGE    1
  39.  
  40. int child_is_running = 0;
  41.  
  42. long old_vectors[10];
  43. long old_trap_0_vector;
  44. long old_trap_f_vector;
  45.  
  46. long set_exception_vector();
  47.  
  48. #if 1 /* def JRDLIB */
  49. /* for st-infru.c */
  50. char * sys_siglist[] = 
  51. {
  52.     "null",
  53.     "alarm",
  54.     "bus error",
  55.     "address error",
  56.     "illegal instruction",
  57.     "div by zero",
  58.     "CHK instruction",
  59.     "TRAPV instruction",
  60.     "priv violation",
  61.     "T-bit trap",
  62.     "Breakpoint",
  63.     "interrupt",
  64.     "quit"
  65. };
  66. #endif
  67.  
  68. /* for st-inflo.c... */
  69. static volatile jmp_buf exec_context, pre_pexec_context;
  70.  
  71. static char  kludge_cmd[MAXPATHLEN];
  72. static char * kludge_argstring;
  73. static char * kludge_env;
  74. static volatile long kludge_pexec_result;
  75.  
  76. static char pexec_stack[256];
  77.  
  78. st_execle_kludge(args, env)
  79. /* BOGON ALERT!!! the caller has 'args' declared as a char **, but
  80.    that's clearly bogus, given the way it's constructed.  Look in
  81.    infcmd.c.  It's really a char *.  I hate C...  */
  82. char * args;
  83. char ** env;
  84. {
  85.     int i, envlen;
  86.     char cmdname[80], argstring[258];
  87.     char * p, * q;
  88.     static char run_already = 0;
  89.  
  90.     if(run_already)
  91.     return -9999;
  92.     else
  93.     run_already = 1;
  94.     
  95.     /* zzz */
  96.     /*
  97.       fprintf_filtered(stderr, "Execle_kludge:\n");
  98.       fprintf_filtered(stderr, "\t'%s'\n", args);
  99.       
  100.       fprintf_filtered(stderr, "\tenv:\n");
  101.       for (i = 0 ; env[i] ; i++)
  102.       fprintf_filtered(stderr, "\t\t'%s'\n", env[i]);
  103.       */
  104.     
  105.     /* construct the environment string */
  106.     envlen = 0;
  107.     for (i = 0; env[i]; i++)
  108.     envlen += strlen(env[i]) + 1;
  109.     envlen += 1;
  110.     
  111.     p = kludge_env = xmalloc(envlen);
  112.     
  113.     for (i = 0; env[i]; i++)
  114.       {
  115.     /*
  116.      * NOTE: in main.c, we converted the PATH environment variable into
  117.      * POSIX form. Here, we convert back into gulam form. Note that the
  118.      * new variable will be shorter than the old, so space is not a
  119.      * problem.
  120.      */
  121.     if (!strncmp (env[i], "PATH=", 5))
  122.       {
  123.         strncpy (p, env[i], 5);
  124.         p += 5;
  125.         for (q = env[i] + 5; *q; q++)
  126.           {
  127.         if (!strncmp (q, "/dev/", 5) && q[5])
  128.           {
  129.             *p++ = q[5];
  130.             *p++ = ':';
  131.             q += 5;
  132.           }
  133.         else if (*q == ':')
  134.           *p++ = ',';
  135.         else if (*q == '/')
  136.           *p++ = '\\';
  137.         else
  138.           *p++ = *q;
  139.           }
  140.       }
  141.     else
  142.       for (q = env[i]; *q; q++)
  143.         *p++ = *q;
  144.     *p++ = '\0';
  145.       }
  146.     *p = '\0';
  147.     
  148.     /* the obligatory cmd line parsing */
  149.     cmdname[0] = '\0';
  150.     /* cmd string has 'exec' in front of it. */
  151.     for (p = args + 4 ; (*p && isspace(*p)) ; p++)
  152.     ;
  153.     for (q = &cmdname[0] ; (*p && !isspace(*p)) ; )
  154.       *q++ = *p++;
  155.     *q = '\0';
  156.     for ( ; (*p && isspace(*p)) ; p++)
  157.     ;
  158.     argstring[1] = '\0';
  159.     for (q = &argstring[1] ; (*p) ; )
  160.     *q++ = *p++;
  161.     *q = '\0';
  162.     argstring[0] = strlen(&argstring[1]);
  163.     unx2dos(&cmdname[0], kludge_cmd);
  164.     
  165.     exception_number = 0;
  166.     old_ipl_2_vector = 
  167.     set_exception_vector(26, ipl_2_vector);    /* our startup trap */
  168.     if (!setjmp(exec_context))
  169.     {
  170.     /* ok, we're either coming thru here the first time, before
  171.        the spawn, or after taking the kludge return.  child_running
  172.        tells us which one */
  173.     if (child_is_running)
  174.     {
  175.         /* something's really fucked here.  We're not supposed to
  176.            be able to come thru here except when we're starting
  177.            things */
  178.         fprintf_filtered(stderr, "Internal error!!! child already running?\n");
  179.         return(0);
  180.     }
  181.     else
  182.     {
  183.         /* set the running flag, arrange to return to that setjmp above,
  184.            and start the child. */
  185.         child_is_running = 1;
  186.         setup_fake_debugger_context(exec_context);
  187.         
  188.         /* if we could be sure of the stack, we'd say...
  189.            Pexec(PE_LOADGO, cmdname, argstring, env);
  190.            but we can't.  instead... */
  191.         
  192.         /*        fprintf_filtered(stderr, "Pexec('%s', '%s')\n",
  193.             &cmdname[0], &argstring[1]);
  194.             */
  195.         /*        kludge_cmd = &cmdname[0]; */
  196.         kludge_argstring = &argstring[0];
  197.         
  198.         if(setjmp(pre_pexec_context))
  199.         {
  200.         free(kludge_env);
  201.         /* we're returning after the child exits.  the stack
  202.            is all fucked here, so reset to top level */
  203.         child_is_running = 0;
  204.         fprintf(stderr, "Program exitted with status %ld\n", 
  205.             kludge_pexec_result);
  206.         exception_number = SIGTRACE;    /* not really... */
  207.         inferior_died();        /* I think this is safe here */
  208.         return_to_top_level();    /* clean up stack and restart */
  209.         return(CHILD_PID_KLUDGE);   /* just in case ... */
  210.         
  211.         }
  212.         /* must make sp point to someplace nonvolatile, as we're going to do 
  213.            a bunch of context switching before we actually 'exit' from this
  214.            pexec. */
  215. #ifndef OLDTOS
  216.  /* default - TOS 1.4 or better required
  217.     use Pexec 3+6 */
  218.  
  219.         asm volatile("\
  220.          movel #_pexec_stack+252,sp
  221.         movel _kludge_env,sp@-
  222.         movel _kludge_argstring,sp@-
  223.         movel #_kludge_cmd,sp@-
  224.         movew #3,sp@-
  225.         movew #0x4B,sp@-
  226.         trap #1
  227.          addw  #16,sp
  228.          clrl  sp@-
  229.          movel d0, sp@-
  230.             clrl  sp@-
  231.          movew #6, sp@-
  232.             movew #0x4B,sp@-
  233.          trap #1
  234.         movel d0,_kludge_pexec_result");
  235. #else
  236. /* pre tos 1.4 -- get a life man 
  237.    use Pexec 0 */        
  238.         asm volatile("\
  239.          movel #_pexec_stack+252,sp
  240.         movel _kludge_env,sp@-
  241.         movel _kludge_argstring,sp@-
  242.         movel #_kludge_cmd,sp@-
  243.         movew #0,sp@-
  244.         movew #0x4B,sp@-
  245.         trap #1
  246.         movel d0,_kludge_pexec_result");
  247. #endif
  248.         
  249. #if 0
  250.         free(kludge_env);
  251.         /* we're returning after the child exits.  the stack
  252.            is all fucked here, so reset to top level */
  253.         child_is_running = 0;
  254.         exception_number = SIGTRACE;    /* not really... */
  255.         inferior_died();        /* I think this is safe here */
  256.         return_to_top_level();        /* clean up stack and restart */
  257. #else
  258.         longjmp(pre_pexec_context, 1);
  259. #endif
  260.     }
  261.     }
  262.     else
  263.     {
  264.     /* we have just spawned the child, and are returning from
  265.        preparing to execute him.  return
  266.        the fake pid so we can continue initialiation */
  267.     set_exception_vector(26, old_ipl_2_vector);
  268.         {
  269.         long * child_sp = (long *)child_context.registers[15];
  270.         child_tpa = (struct tpa * )child_sp[1];
  271.         /*      fprintf_filtered(stderr, "child tpa at %X\n", child_tpa); */
  272.         relocate_apropriate_symbols(child_tpa->text_base);
  273.         exception_number = 0;
  274.         }
  275.     }
  276.     return(CHILD_PID_KLUDGE);
  277. }
  278.  
  279. #if 1 /* def JRDLIB */
  280. /* called various places */
  281. int kill(fake_pid, signal)
  282. int fake_pid;
  283. int signal;
  284. {
  285.   extern void request_quit();
  286.  
  287.     if (fake_pid == CHILD_PID_KLUDGE)
  288.     {
  289.     /* if the child is running, then TOS thinks we're it, so just exit */
  290.     if (child_is_running)
  291.         Pterm0();
  292.     /* doesn't return... */
  293.     else
  294.         fprintf_filtered(stderr, "Internal error: attempt to kill when child not running\n");
  295.     }
  296.     else if (fake_pid == getpid ())
  297.       {
  298.     if (signal == SIGINT)
  299.       request_quit();
  300.       }
  301.     else
  302.     fprintf_filtered(stderr, "You can't kill pid %d, bozo!\n", fake_pid);
  303.     
  304.     return(-1);
  305. }
  306. #endif
  307.  
  308. /* called from various places, mostly st-infru.c */
  309. int st_wait_kludge(w)
  310. WAITTYPE * w;
  311. {
  312.     /*  fprintf_filtered(stderr, "st-wait-kludge: running %d exc %d\n",
  313.       child_is_running, exception_number);    */
  314.     if (child_is_running)
  315.     {
  316.     WSETSTOP(*w, exception_number);
  317.     return(CHILD_PID_KLUDGE);
  318.     }
  319.     else
  320.     {
  321.     WSETEXIT(*w, 0);
  322.     return(-1);
  323.     }
  324. }
  325.  
  326.  
  327. static char *regcomp_error = 0;
  328. static regexp *compiled_regex = 0;
  329.  
  330. /* Remember the last error message from regcomp */
  331. void regerror(message)
  332. char *message;
  333. {
  334.     regcomp_error = message;
  335. }
  336.  
  337. char *re_comp(regex)
  338. char *regex;
  339. {
  340.     regcomp_error = NULL;
  341.     if (compiled_regex) free(compiled_regex);
  342.     if (compiled_regex = regcomp(regex))
  343.     return NULL;
  344.     else
  345.     return regcomp_error;
  346. }
  347.  
  348. int re_exec(buffer)
  349. char *buffer;
  350. {
  351.     if (compiled_regex)
  352.     return regexec(compiled_regex, buffer, 1);
  353.     else
  354.     return -1;
  355. }
  356.  
  357. /* low-level exception-handling support */
  358.  
  359. long set_exception_vector(n, entry_point)
  360. /* (declare (values old-vector)) */
  361. int n;
  362. long entry_point;    /* really a function... */
  363. {
  364.     long old_vector;
  365.     /*  fprintf_filtered(stderr, "set exception %d %X", n, entry_point); */
  366.     old_vector = (long)Setexc(n, entry_point);    /* better way? */
  367.     /*  fprintf_filtered(stderr, " -> %X\n", old_vector); */
  368.     return(old_vector);
  369. }
  370.  
  371. set_all_exception_vectors()
  372. {
  373.     old_vectors[2] = set_exception_vector(2, exception_2_vector);
  374.     old_vectors[3] = set_exception_vector(3, exception_3_vector);
  375.     old_vectors[4] = set_exception_vector(4, exception_4_vector);
  376.     old_vectors[5] = set_exception_vector(5, exception_5_vector);
  377.     old_vectors[6] = set_exception_vector(6, exception_6_vector);
  378.     old_vectors[7] = set_exception_vector(7, exception_7_vector);
  379.     old_vectors[8] = set_exception_vector(8, exception_8_vector);
  380.     old_vectors[9] = set_exception_vector(9, exception_9_vector);
  381.     
  382.     old_trap_0_vector = set_exception_vector(32, trap_0_vector);
  383.     old_trap_f_vector = set_exception_vector(47, trap_f_vector);
  384.     /* we don't set the ipl 2 vector here as we'll only use it once, 
  385.        when starting */
  386. }
  387.  
  388. restore_all_exception_vectors()
  389. {
  390.     set_exception_vector(2, old_vectors[2]);
  391.     set_exception_vector(3, old_vectors[3]);
  392.     set_exception_vector(4, old_vectors[4]);
  393.     set_exception_vector(5, old_vectors[5]);
  394.     set_exception_vector(6, old_vectors[6]);
  395.     set_exception_vector(7, old_vectors[7]);
  396.     set_exception_vector(8, old_vectors[8]);
  397.     set_exception_vector(9, old_vectors[9]);
  398.     
  399.     set_exception_vector(32, old_trap_0_vector);
  400.     set_exception_vector(47, old_trap_f_vector);
  401. }
  402.  
  403. /* -- here's a bunch of stuff for controlling the 'child' program */
  404.  
  405. /* force the child process to exit */
  406. st_child_exit()
  407. {
  408.     /*  fprintf_filtered(stderr, "st_child_exit\n"); */
  409.     if (child_is_running)
  410.       Pterm0();
  411.     else
  412.     fprintf_filtered(stderr, "Internal error: child not running?\n");
  413. }
  414.  
  415. /* continue after bpt */
  416. st_child_continue()
  417. {
  418.     /*  fprintf_filtered(stderr, "st_child_continue\n"); */
  419.     if (child_is_running)
  420.     {
  421.     set_all_exception_vectors();        /* set our traps */
  422.     child_context.sr &= 0x7FFF;        /* clear T bit */
  423.     asm volatile("trap #0");            /* swap context */
  424.     /* child runs here, and returns to us */
  425.     restore_all_exception_vectors();    /* and put our traps back */
  426.     }
  427.     else
  428.     fprintf_filtered(stderr, "Internal error: child not running?\n");
  429. }
  430.  
  431. /* single step */
  432. st_child_single_step()
  433. {
  434.     /*  fprintf_filtered(stderr, "st_child_single_step\n"); */
  435.     if (child_is_running)
  436.     {
  437.     set_all_exception_vectors();        /* set our traps */
  438.     child_context.sr |= 0x8000;        /* set T bit */
  439.     asm volatile("trap #0");            /* swap context */
  440.     restore_all_exception_vectors();    /* and put our traps back */
  441.     }
  442.     else
  443.     fprintf_filtered(stderr, "Internal error: child not running?\n");
  444. }
  445.  
  446. /* read a register from saved copies */
  447. long st_child_read_register(regaddr)
  448. int regaddr;
  449. {
  450.     long result;
  451.     
  452.     /*  fprintf_filtered(stderr, "st_child_read_register %X ", regaddr);    */
  453.     if (child_is_running)
  454.     {
  455.     if ((regaddr >> 2) == PS_REGNUM)
  456.         result = child_context.sr;
  457.     else
  458.     {
  459.         result = ( *(long * )(regaddr + (char * )&child_context));
  460.         /*
  461.           if ((exception_number == 2) || (exception_number == 3))
  462.           {
  463.           fprintf_filtered(stderr, "Adjusting pc for trap %d %08X->%08X\n", 
  464.           exception_number, result, result+8);
  465.           result += 8;
  466.           }
  467.           */
  468.     }
  469.     /*    fprintf_filtered(stderr, "-> %X\n", result);    */
  470.     }
  471.     else
  472.     fprintf_filtered(stderr, "Child is not running\n");
  473.     return(result);
  474. }
  475.  
  476. /* write a register to saved copies */
  477. st_child_write_register(regaddr, value)
  478. int regaddr, value;
  479. {
  480.     /*  fprintf_filtered(stderr, "st_child_write_register %X <- %X\n", regaddr, value); */
  481.     if (child_is_running)
  482.     {
  483.     if ((regaddr >> 2) == PS_REGNUM)
  484.         child_context.sr = value;
  485.     else
  486.         *(long * )(regaddr + (char * )(&child_context)) = value;
  487.     }
  488.     else
  489.     fprintf_filtered(stderr, "Child is not running\n");
  490. }
  491.  
  492. void st_bus_error_handler ()
  493. {
  494.   asm volatile ("andw #~0x2000,sr");
  495.   error ("Bus error while reading from or writing to child memory.");
  496. }
  497.  
  498. /* read a 32-bit word from child memory */
  499. st_child_read_word(addr)
  500. volatile long * addr;
  501. {
  502.     long result;
  503.     long old_buserror;
  504.     
  505.     /*  fprintf(stderr, "st_child_read_word %X", addr); */
  506.     /* report bus errors */
  507.     old_buserror = (long) Setexc (2, st_bus_error_handler);
  508.     result = *addr;
  509.     (void) Setexc (2, old_buserror);
  510.     /*  fprintf(stderr, "->%X\n", result);    */
  511.     return(result);
  512. }
  513.  
  514. /* write a 32-bit word to child mem */
  515. st_child_write_word(addr, value)
  516. long * addr;
  517. volatile long value;
  518. {
  519.     long old_buserror;
  520.     /*  fprintf(stderr, "st_child_write_word %X <- %X\n", addr, value); */
  521.     /* report bus errors */
  522.     old_buserror = (long) Setexc (2, st_bus_error_handler);
  523.     *addr = value;
  524.     (void) Setexc (2, old_buserror);
  525. }
  526.  
  527. #define DEBUG 1
  528.  
  529. #ifdef DEBUG
  530. static char *d_namespace[] =
  531. {  "UNDEF", "VAR", "STRUCT", "LABEL"    };
  532.  
  533. static char *d_aclass[] = 
  534. {
  535. "LOC_UNDEF", "LOC_CONST", "LOC_STATIC", "LOC_REGISTER", "LOC_ARG", "LOC_LOCAL",
  536. "LOC_TYPEDEF", "LOC_LABEL", "LOC_BLOCK", "LOC_EXTERNAL", "LOC_CONST_BYTES"
  537. };
  538.     
  539. #endif
  540.  
  541. /********************************************************************
  542.   
  543.   This next thing is the symbol-table relocator.  We use it after 
  544.   starting a child program.
  545.   
  546.   Walk thru all symbol tables looking for syms in VAR_NAMESPACE.
  547.   When find one, if its address_class is LOC_STATIC, relocate its
  548.   value by base_address.  Then cross fingers and pray...
  549.   
  550.   */
  551. relocate_apropriate_symbols(base_address)
  552. long base_address;
  553. {
  554.     struct symtab * s;
  555.     struct symbol * sym;
  556.     struct blockvector * bv, *last_bv = 0;
  557.     struct block * block;
  558.     struct linetable * l;
  559.     int nsyms, symnum, i;
  560.     extern char *version;
  561.  
  562. #ifdef DEBUG
  563.     if(atari_debug)
  564.     {
  565.       fprintf_filtered(stderr,"Reloc constant %ld %X\n", base_address, base_address);
  566.     }
  567. #endif
  568.     for (s = symtab_list ; s ; s = s->next)
  569.     {
  570.     l = LINETABLE(s);
  571. #ifdef DEBUG
  572.     if(atari_debug)
  573.     {
  574.       fprintf_filtered(stderr,
  575.           "reloc syms table %X file '%s' linetable %08X(%ld) %d items\n",
  576.         s, s->filename, l,l, l->nitems);
  577.         }
  578. #endif
  579.         { 
  580.         int n = l->nitems;
  581.         struct linetable_entry *item;
  582.         
  583. #ifdef DEBUG
  584.         if(atari_debug && (n <= 0))
  585.         {
  586.         fprintf_filtered(stderr,"*********linetable with %d items\n", n);
  587.         }
  588. #endif        
  589.         for (i = 0 ; i < n ; i++)
  590.         {
  591.         item = &(l->item[i]);
  592. #ifdef DEBUG
  593.         if(atari_debug)
  594.         {
  595.           fprintf_filtered(stderr, "    %d: line %d %X(%ld)->%X(%ld)\n",
  596.             i, item->line, item->pc, item->pc,
  597.             item->pc+base_address, item->pc+base_address);
  598.             }
  599. #endif
  600.         item->pc += base_address;
  601.         }
  602.     }
  603.     bv = BLOCKVECTOR (s);
  604.     if (bv == last_bv)
  605.     {
  606.         /* already relocated */
  607. #ifdef DEBUG
  608.         if(atari_debug)
  609.         {
  610.           fprintf_filtered(stderr,"Skipping block vector %X(%d) already relocated\n", bv,bv); 
  611.         }
  612. #endif
  613.         continue;
  614.     }
  615.     last_bv = bv;
  616.     for (i = 0 ; i < BLOCKVECTOR_NBLOCKS(bv) ; i++)
  617.     {
  618.         block = BLOCKVECTOR_BLOCK (bv, i);
  619. #ifdef DEBUG
  620.         if(atari_debug)
  621.         {
  622.           fprintf_filtered(stderr, " block %d: in %X(%d)\n", i, bv, bv);
  623.         }
  624. #endif
  625.         relocate_apropriate_block_symbols(block, base_address);
  626.     }
  627.     }
  628. #ifdef DEBUG
  629.     if(atari_debug)
  630.     {
  631.       fprintf_filtered(stderr,"Relocatings %d misc functions\n", misc_function_count);
  632.     }
  633. #endif
  634.     /* relocate the misc functions */
  635.     for (i = 0; i < misc_function_count; i++)
  636.     {
  637. #ifdef DEBUG
  638.     if(atari_debug > 1)
  639.     {
  640.       fprintf_filtered(stderr, "%s: %X(%ld)->%X(%ld)\n", misc_function_vector[i].name,
  641.             misc_function_vector[i].address, misc_function_vector[i].address,
  642.         misc_function_vector[i].address+base_address, misc_function_vector[i].address+base_address);
  643.         }
  644. #endif    
  645.     misc_function_vector[i].address += base_address;
  646.     }
  647.     
  648. }
  649.  
  650. relocate_apropriate_block_symbols(block, base_address)
  651. struct block * block;
  652. long base_address;
  653. {
  654.     struct symbol * sym;
  655.     int nsyms, symnum;
  656.     
  657.     /*    for ( ; block ; block = BLOCK_SUPERBLOCK(block)) */
  658.     {
  659.     BLOCK_START(block) += base_address;
  660.     BLOCK_END(block) += base_address;
  661.     nsyms = BLOCK_NSYMS (block);
  662. #ifdef DEBUG
  663.     if(atari_debug)
  664.     {
  665.       fprintf_filtered(stderr, " %d syms block %X(%ld)\n", nsyms, block, block);
  666.         }
  667. #endif
  668.     for (symnum = 0 ; symnum < nsyms ; symnum++)
  669.     {
  670.         sym = BLOCK_SYM (block, symnum);
  671. #ifdef DEBUG
  672.         if(atari_debug)
  673.         {
  674.           fprintf_filtered(stderr, "  sym %d %X name '%s'",
  675.               symnum, sym, SYMBOL_NAME(sym));
  676.         }
  677. #endif
  678.         if ((sym->namespace == VAR_NAMESPACE) &&
  679.         ((sym->class == LOC_STATIC) || (sym->class == LOC_LABEL)))
  680.         {
  681. #ifdef DEBUG
  682.         if(atari_debug)
  683.         {
  684.         fprintf_filtered(stderr, " is relocatable: (%s, %s) %X->%X  %ld->%ld\n",
  685.             d_namespace[sym->namespace], d_aclass[sym->class],
  686.             sym->value.value, sym->value.value + base_address,
  687.             sym->value.value, sym->value.value + base_address);
  688.             }
  689. #endif
  690.         sym->value.value += base_address;
  691.         }
  692.         else if (sym->class == LOC_BLOCK)
  693.         {
  694. #ifdef DEBUG
  695.         if(atari_debug)
  696.         {
  697.         fprintf_filtered(stderr, " is a LOC_block(%s %s)... %X\n",
  698.         d_namespace[sym->namespace], d_aclass[sym->class], sym->value.block);
  699.             }
  700. #endif
  701. #if 0
  702.         relocate_apropriate_block_symbols(sym->value.block, base_address);
  703. #else
  704.             {
  705.             struct block * bl = sym->value.block;
  706. #ifdef DEBUG0
  707.             if(atari_debug)
  708.             {
  709.             fprintf_filtered(stderr, "  start %X->%X\n", 
  710.                 BLOCK_START(bl), BLOCK_START(bl) + base_address);
  711.             }
  712. #endif
  713.             /* BLOCK_START(bl) += base_address; */
  714. #ifdef DEBUG0
  715.             if(atari_debug)
  716.             {
  717.             fprintf_filtered(stderr, "  end   %X->%X\n", 
  718.                 BLOCK_END(bl), BLOCK_END(bl) + base_address);
  719.             }
  720. #endif
  721.             /* BLOCK_END(bl) += base_address; */
  722.             }
  723. #endif
  724. #ifdef DEBUG
  725.         if(atari_debug)
  726.         {
  727.           fprintf_filtered(stderr, " ...end block\n");
  728.             }
  729. #endif
  730.         }
  731.         else
  732.         {
  733. #ifdef DEBUG
  734.         if(atari_debug)
  735.         {
  736.           fprintf_filtered(stderr, " is not relocatable: (%s, %s)\n",
  737.             d_namespace[sym->namespace], d_aclass[sym->class]);
  738.             }
  739. #endif
  740.         }
  741.     }
  742.     }
  743. }
  744.